package com.xingkeduo.dao.workpad;


import com.xingkeduo.model.param.AttendancePageParam;
import com.xingkeduo.model.param.AttendanceParam;
import com.xingkeduo.model.po.TStaffAttendance;
import com.xingkeduo.model.vo.CmsStaffAttendancePageVo;
import com.xingkeduo.model.vo.StaffSchedulingVo;
import com.xingkeduo.model.vo.StoreSchedulingVo;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

public interface TStaffAttendanceMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_staff_attendance
     *
     * @mbggenerated
     */
    int deleteByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_staff_attendance
     *
     * @mbggenerated
     */
    int insert(TStaffAttendance record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_staff_attendance
     *
     * @mbggenerated
     */
    TStaffAttendance selectByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_staff_attendance
     *
     * @mbggenerated
     */
    List<TStaffAttendance> selectAll();

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_staff_attendance
     *
     * @mbggenerated
     */
    int updateByPrimaryKey(TStaffAttendance record);



    int batchInsertForInit(@Param("attendanceList") List<TStaffAttendance> attendanceList);

    int batchUpdateForArrange(@Param("attendanceList") List<TStaffAttendance> attendanceList);

    /** 根据传入时间找出对应一周内发型师排班情况 **/
    List<TStaffAttendance> selectBySelectedDate(@Param("dateOfMonday") String dateOfMonday,
                                                @Param("dateOfSunday") String dateOfSunday,
                                                @Param("storeId") Long storeId,
                                                @Param("staffId") Long staffId);

    /** 根据 发型师Id 时间查出排班情况 -- 获取排班列表使用 **/
    List<TStaffAttendance> selectByStaffIAndDate(@Param("staffId") Long staffId,
                                                 @Param("selectDate") String selectDate);

    /** 根据 发型师Id 时间查出排班情况 -- 获取打卡状态使用 **/
    List<TStaffAttendance> selectByStaffIAndDateOfClockIn(@Param("staffId") Long staffId,
                                                 @Param("selectDate") String selectDate);

    /** 根据 考勤Id 修改打卡状态 **/
    int updateByStaffAttendanceId(@Param("staffAttendanceId") Integer staffAttendanceId,
                                  @Param("realWorkStartTime") Date realWorkStartTime,
                                  @Param("realWorkStopTime") Date realWorkStopTime,
                                  @Param("status") boolean status,
                                  @Param("workStatus") int workStatus);

    /** 获取当天店铺所有发型师打卡信息 **/
    List<TStaffAttendance> selectStaffAttendanceByStoreId(@Param("storeId") Long storeId, @Param("selectDate") String selectDate);

    List<TStaffAttendance> selectAttendanceOfPersonal(@Param("param") AttendanceParam param);

    /** 根据店铺id获取店铺所有绑定员工 排班总天数 and 发型师info **/
    List<StaffSchedulingVo> selectStaffSchedulingByStoreId(@Param("storeId") Long storeId,
                                                           @Param("selectDate") String selectDate);

    /** 获取发型师 所有店铺总排班天数 and 店铺名称 **/
    List<StoreSchedulingVo> selectStoreSchedulingByStaffId(@Param("staffId") Long staffId,
                                                           @Param("storeName") String storeName,
                                                           @Param("selectDate") String selectDate);

    int unableStaffAttendanceByStoreIdAndStaffIdAndWeek(@Param("storeId") Long storeId,@Param("staffId") Long staffId,@Param("dateList") List<Date> dateList);


    /** 根据店铺id 当周周一的时间 重置所有早晚全班的状态及时间**/
    int updateResetAttendanceTypeByAfterDateAndShopId(@Param("dateOfMonday") Date dateOfMonday, @Param("storeId") Long storeId, @Param("modifier") Long modifier);

    /** 根据当前时间 店铺id 清空当天之后所有的排班时间 **/
    int updateEmptyAttendanceTimeByAfterDateAndShopId(@Param("nowDate") Date nowDate, @Param("storeId") Long storeId, @Param("modifier") Long modifier);

    /** 根据发型师Id 查找历史打卡店铺 **/
    List<TStaffAttendance> selectAttendanceStoresByStaffId(@Param("staffId") Long staffId, @Param("selectDate") String selectDate);

    int countAttendanceByStaffIdAndStoreId(@Param("storeId") Long storeId,
                                           @Param("staffId") Long staffId,
                                           @Param("selectDate") Date selectDate);

    List<String> selectAttendanceByStaffIdAndStoreId(@Param("storeId") Long storeId,
                                                     @Param("staffId") Long staffId,
                                                     @Param("selectDate") String selectDate);

    /** 根据店铺id 修改当前周及未来的考勤状态为临时 **/
    int updateAttendanceTypeByStoreId(@Param("storeId") Long storeId, @Param("selectDate") String selectDate);


    Date getLastStaffAttendanceDateByStaffIdAndStoreId(@Param("storeId") Long storeId,
                                                       @Param("staffId") Long staffId);
    /** 根据上下班状态 时间 获取排班Id集合 **/
    List<TStaffAttendance> selectAttendanceIdByStatusAndDate(@Param("status") int status, @Param("selectDate") String selectDate);

    /** 根据排班id批量 把status 置为0 下班状态 **/
    int batchUpdateStatusById(@Param("ids") List<Integer> ids);
    /** 后台CMS查询分页列表**/
     List<TStaffAttendance> selectStaffAttendancePageList(@Param("param") AttendancePageParam attendancePageParam);
}